import 'dart:ui' as ui show window;
import 'package:flutter/material.dart' show MediaQueryData, kToolbarHeight;

class DensityUtil {
  /// 屏幕宽
  ///
  static double get width {
    MediaQueryData mediaQuery = MediaQueryData.fromWindow(ui.window);
    return mediaQuery.size.width;
  }

  /// 屏幕高
  ///
  static double get height {
    MediaQueryData mediaQuery = MediaQueryData.fromWindow(ui.window);
    return mediaQuery.size.height;
  }

  /// 状态栏高度
  ///
  static double get topSafeHeight {
    MediaQueryData mediaQuery = MediaQueryData.fromWindow(ui.window);
    return mediaQuery.padding.top;
  }

  /// 导航栏高度
  ///
  static double get appBarHeight {
    return DensityUtil.topSafeHeight + kToolbarHeight;
  }

  /// 底部状态栏高度
  ///
  static double get bottomSafeHeight {
    MediaQueryData mediaQuery = MediaQueryData.fromWindow(ui.window);
    return mediaQuery.padding.bottom;
  }

  static double get childAspectRatio {
    return (width / 9 * 7 - 40) / 2 / 27;
  }
}
